package model

import (
	"base"
)

type ClientStatus uint8

const (
	Client_NoLoginStatus ClientStatus = iota
	Client_PlayStatus
)

type Client struct {
	id     base.ClientId
	gateId base.AgentId
	status ClientStatus
	player *Player
}

func NewClient(id base.ClientId, gateId base.AgentId) *Client {
	result := new(Client)
	result.id = id
	result.gateId = gateId
	result.status = Client_NoLoginStatus

	return result
}

func (client *Client) Id() base.ClientId {
	return client.id
}

func (client *Client) GateId() base.AgentId {
	return client.gateId
}

func (client *Client) Player() *Player {
	return client.player
}

func (client *Client) SetPlayer(player *Player) {
	client.player = player
}

func (client *Client) Status() ClientStatus {
	return client.status
}

func (client *Client) SetStatus(status ClientStatus) {
	client.status = status
}

func (client *Client) Clear() {
	client.status = Client_NoLoginStatus
	if client.player != nil {
		client.player.SetClient(nil)
		client.player = nil
	}
}
